const MyPromise = require("./myPromsie");

const p = new MyPromise((resolve, reject) => {
  //   resolve("fulfilled");
  setTimeout(() => {
    resolve("success");
    //   reject("error");
  }, 1000);
});

let p2 = p
  .then(
    (value) => {
      console.log("fulfilled1:" + value);
      return new MyPromise((resolve, reject) => {
        resolve("fulfilledSecond: " + value);
      });
    },
    (reason) => {
      console.log("rejected1:" + reason);
    }
  )
  .then(
    (v) => {
      console.log(v);
    },
    (r) => {
      console.log("Error" + r);
    }
  );
console.log(p2);

// p.then(
//   (value) => {
//     console.log("fulfilled2:" + value);
//   },
//   (reason) => {
//     console.log("rejected2:" + reason);
//   }
// );
